<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		
		<script type="text/javascript">
			//数组定义
			// var arr = [];
			//var arr = new Array();
			
			/*var arr = [2,,3,];//,最后一位忽略*/
			
			/*var arr = new Array(2);//数组长度
			var arr = new Array(2,2);//定义数组*/
			
			/*
			 * 改变原数组:
			 * push pop shift unshift sort reverse 
			 * splice
			 * 
			 * 不改变原数组
			 * concat,join-->split,toString,slice
			 */
			
			
			//push
/*			var arr = [];
			arr.push(10);
			arr.push(11,12);*/
			/*Array.prototype.push = function(){
				for (var i = 0; i < arguments.length; i++) {
					this[this.length] = arguments[i];
				}
				return this.length;
			}
			var arr = [];*/
			
			//pop 删除数组最后一位，返回
			/*var arr = [1,2,3];*/
			//shift/unshift 在首位
			
			//reverse 反序
			
			//splice
			/*var arr = [1,1,2,2,3,3];
			arr.splice(1,2);//1,2,3,3
			arr.splice(1,2,4,5);//1,4,5,3*/
			
			/*var arr = [1,3,5,4,10];
			arr.sort(function (a,b){
				return a < b;
			});*/
			
			/*//乱序
			var arr = [1,2,3,4,5,6,7,8];
			arr.sort(function (a,b){
				return Math.random() - 0.5;
			})
			console.log(arr);*/
			
			/*var cheng = {
				name : "cheng",
				age: 18,
				sex : 'male',
				face : "handsom"
			}
			
			var deng = {
				name : "deng",
				age : 40,
				sex : undefined,
				face : "amazing"
			}
			
			var zhang = {
				name :"zhang",
				age : 20,
				sex : "male"
			}
			
			var arr = [cheng,deng,zhang];
			arr.sort(function (a,b){
				return a.age > b.age;
			});*/
			
			
			/*var arr1 = [1,2,3,4,5];
			var arr2 = [6,7,8];
			var arr = arr1.concat(arr2);*/
			
			/*//slice(从该为开始，截取到第几位)
			var arr = [1,2,3,4,5]; 
			console.log(arr.slice(1,3));//2,3
			console.log(arr.slice(2));//
			console.log(arr.slice(-2));//*/
			
			/*var arr = [1,2,3,4,5]; 
			var str = arr.join("-");
			console.log(str);
			var arr1 = str.split("-");*/
			
			
			
			
			
			
		</script>
	</body>
</html>
